  // db/index.js
const Sequelize = require('sequelize');
const dbConfig = require('./config.json');

// 选择当前环境的数据库配置
const env = process.env.NODE_ENV || 'development';
const config = dbConfig[env];

const sequelize = new Sequelize(config.database, config.username, config.password, {
  host: config.host,
  port: 5432, // mysql默认是 3306，pg5432
  dialect: config.dialect,
});

module.exports = sequelize;